package com.csj.picture.controller;

import com.csj.picture.client.AiInterfaceClient;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import org.springframework.http.codec.ServerSentEvent;

@RestController
@RequestMapping()
public class AiController {

    private final AiInterfaceClient aiInterfaceClient;

    public AiController(AiInterfaceClient aiInterfaceClient) {
        this.aiInterfaceClient = aiInterfaceClient;
    }

    /**
     * 代理接口，转发请求到原接口并返回相同结果
     */
    @GetMapping("/ai/chat")
    public Flux<ServerSentEvent<String>> proxyChat(int memoryId, String message) {
        // 直接调用客户端方法，返回与原接口完全一致的响应
        return aiInterfaceClient.callChatInterface(memoryId, message);
    }
}